package mediator;


/**
 * 会限制对象之间的直接交互， 迫使它们通过一个中介者对象进行合作
 */
public class Test {
    public static void main(String[] args) {
        ChatRoom chatRoom = new ChatRoom("ChatRoom");
        User user1 = new User("user1");
        User user2 = new User("user2");
        User user3 = new User("user3");

        user1.addToChatRoom(chatRoom);
        user2.addToChatRoom(chatRoom);
        user3.addToChatRoom(chatRoom);

        user1.sendMessage("Hello, I'm user1", "ChatRoom");
    }
}
